package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhCarGroup;
import com.laowang.project.system.service.MyCyhCarGroupService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 车友群Controller
 *
 * @author laowang
 * @date 2023-08-29
 */
@Api(tags = "车友群接口")
@RestController
@RequestMapping("/carGroups")
public class MyCyhCarGroupController extends BaseController {

    @Autowired
    private MyCyhCarGroupService myCyhCarGroupService;

    @ApiOperation(value = "小程序端 查询车友群列表",notes = "")
    @GetMapping("/web/list")
    public AjaxResult weblist( ) {
        List<MyCyhCarGroup> list = myCyhCarGroupService.selectMyCyhCarGroupListWeb(null);
        return AjaxResult.success("操作成功",list);
    }



    /**
     * 查询车友群列表
     */
    @ApiOperation(value = "查询车友群列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carGroups:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyCyhCarGroup myCyhCarGroup) {
        startPage();
        List<MyCyhCarGroup> list = myCyhCarGroupService.selectMyCyhCarGroupList(myCyhCarGroup);
        return getDataTable(list);
    }

    /**
     * 导出车友群列表
     */
    @ApiOperation(value = "导出车友群列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carGroups:export')")
    //@Log(title = "车友群", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyCyhCarGroup myCyhCarGroup) {
        List<MyCyhCarGroup> list = myCyhCarGroupService.selectMyCyhCarGroupList(myCyhCarGroup);
        ExcelUtil<MyCyhCarGroup> util = new ExcelUtil<MyCyhCarGroup>(MyCyhCarGroup.class);
        return util.exportExcel(list, "carGroup");
    }

    /**
     * 获取车友群详细信息
     */
    @ApiOperation(value = "获取车友群详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carGroups:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhCarGroupService.selectMyCyhCarGroupById(id));
    }

    /**
     * 新增车友群
     */
    @ApiOperation(value = "新增车友群",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carGroups:add')")
    //@Log(title = "车友群", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhCarGroup myCyhCarGroup) {
        return toAjax(myCyhCarGroupService.insertMyCyhCarGroup(myCyhCarGroup));
    }

    /**
     * 修改车友群
     */
    @ApiOperation(value = "修改车友群",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carGroups:edit')")
    //@Log(title = "车友群", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhCarGroup myCyhCarGroup) {
        return toAjax(myCyhCarGroupService.updateMyCyhCarGroup(myCyhCarGroup));
    }

    /**
     * 删除车友群
     */
    @ApiOperation(value = "删除车友群",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carGroups:remove')")
    //@Log(title = "车友群", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhCarGroupService.deleteMyCyhCarGroupByIds(ids));
    }
}
